package com.kwt.learn.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Callable01 {

    static class Task implements Callable<String> {
        @Override
        public String call() throws Exception {
            Thread.sleep(6000);
            return "call";
        }
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> stringFutureTask = new FutureTask<String>(new Task());
        new Thread(stringFutureTask).start();
        while (!stringFutureTask.isDone()) {
            String s = stringFutureTask.get();
            System.err.println(s);
        }
    }
}
